import "./styles/tailwind.css";
import { createApp } from "vue";
import App from "./App.vue";
import router, { setupRouter } from "./router";
import { setupStore } from "@/store";
import { useMessage } from "naive-ui";
import { setupNaive } from "@/plugins";
import { AppProvider } from "@/components/Application"

async function bootstrap() {
  const appProvider = createApp(AppProvider);

  const app = createApp(App);

  // 注册全局常用的 naive-ui 组件
  setupNaive(app);

  // 挂载状态管理
  setupStore(app);

  // 优先挂载一下Provider 解决路由守卫，Axios中可使用，Dialog，Message等之类组件
  appProvider.mount("#appProvider", true);

  // 挂载路由
  await setupRouter(app);

  // 路由准备就绪后挂载App实例
  await router.isReady();

  app.mount("#app", true);
}

void bootstrap();
